package com.sfddata.musicpillow.user.service.impl;

import com.sfddata.musicpillow.common.utils.Query;
import org.springframework.stereotype.Service;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.sfddata.musicpillow.common.utils.PageUtils;

import com.sfddata.musicpillow.user.dao.UserEquipRelationDao;
import com.sfddata.musicpillow.user.entity.UserEquipRelationEntity;
import com.sfddata.musicpillow.user.service.UserEquipRelationService;


@Service("userEquipRelationService")
public class UserEquipRelationServiceImpl extends ServiceImpl<UserEquipRelationDao, UserEquipRelationEntity> implements UserEquipRelationService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        IPage<UserEquipRelationEntity> page = this.page(
                new Query<UserEquipRelationEntity>().getPage(params),
                new QueryWrapper<UserEquipRelationEntity>()
        );

        return new PageUtils(page);
    }

    @Override
    public void removeByEquipAndUser(Integer equipId, Integer userId) {

        QueryWrapper<UserEquipRelationEntity> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("equip_id", equipId);
        queryWrapper.eq("user_id", userId);
        baseMapper.delete(queryWrapper);
    }

}